//
//  HomeSectionHeaderView.m
//  LovingPartyBuilding
//
//  Created by 刘应平 on 17/4/28.
//  Copyright © 2017年 刘应平. All rights reserved.
//

#import "HomeSectionHeaderView.h"
/**  40  */
@implementation HomeSectionHeaderView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
        [self addSubview:self.titleLabel];
        [self addSubview:self.detailLabel];
        [self addSubview:self.imageView];
        [self addSubview:self.moreLabel];
        
        self.titleLabel.sd_layout
        .leftSpaceToView(self, 15 * [UIScreen zj_screenWScale])
        .topSpaceToView(self, 10 * [UIScreen zj_screenHScale])
        .heightIs(20 * [UIScreen zj_screenHScale])
        .widthIs(90 * [UIScreen zj_screenWScale]);
        
        self.detailLabel.sd_layout
        .leftSpaceToView(self.titleLabel,0)
        .heightIs(20 * [UIScreen zj_screenHScale])
        .topEqualToView(self.titleLabel)
        .widthIs(150 * [UIScreen zj_screenWScale]);
        
        self.imageView.sd_layout
        .rightSpaceToView(self,15 * [UIScreen zj_screenWScale])
        .topSpaceToView(self,12.5 * [UIScreen zj_screenHScale])
        .heightIs(15 * [UIScreen zj_screenHScale])
        .widthIs(15 * [UIScreen zj_screenWScale]);
        
        self.moreLabel.sd_layout.topEqualToView(self.imageView)
        .rightSpaceToView(self.imageView,2 * [UIScreen zj_screenWScale])
        .heightIs(15 * [UIScreen zj_screenHScale])
        .widthIs(40 * [UIScreen zj_screenWScale]);
        
        self.tapView = [UIView new];
        self.tapView.userInteractionEnabled = YES;
        self.tapView.backgroundColor = [UIColor clearColor];
        [self addSubview:self.tapView];
        self.tapView.sd_layout.rightEqualToView(self.imageView).topEqualToView(self).heightIs(40 * [UIScreen zj_screenHScale]).widthIs(50 * [UIScreen zj_screenWScale]);
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapLabel:)];
        [self.tapView addGestureRecognizer:tap];
        
        
       self.under = [UIView new];
        self.under.backgroundColor = [UIColor themeGrayColor];
        [self addSubview:self.under];
        self.under.sd_layout.leftEqualToView(self).widthIs(self.width).heightIs(1).bottomEqualToView(self);
        
    }
    return self;
}



#pragma mark - 私有方法
- (void)tapLabel:(UITapGestureRecognizer *)tap{

    if (self.delegate && [self.delegate respondsToSelector:@selector(homeSectionHeaderWithVeiw: ClickSection:)]) {
        [self.delegate homeSectionHeaderWithVeiw:self ClickSection:self.sectionIndex];
    }
}

#pragma mark - 监听事件


#pragma mark - 协议代理


#pragma mark - getter
- (UILabel *)titleLabel{
    if (!_titleLabel) {
        _titleLabel = ({
            UILabel *label = [UILabel new];
            label.textAlignment = NSTextAlignmentLeft;
            label.textColor = [UIColor textBlackColor];
            label.backgroundColor = [UIColor clearColor];
            label.font = [UIFont systemFontOfSize:16 * [UIScreen zj_textFontScale]];
            label;
        });
    }
    return _titleLabel;
}


- (UILabel *)detailLabel{
    if (!_detailLabel) {
        _detailLabel = ({
            UILabel *label = [UILabel new];
            label.textAlignment = NSTextAlignmentLeft;
            label.textColor = [UIColor themeColor];
            label.backgroundColor = [UIColor clearColor];
            label.font = [UIFont systemFontOfSize:14 * [UIScreen zj_textFontScale]];
            label;
        });
    }
    return _detailLabel;
}

- (UILabel *)moreLabel{
    if (!_moreLabel) {
        _moreLabel = ({
            UILabel *label = [UILabel new];
            label.textAlignment = NSTextAlignmentRight;
            label.textColor = [UIColor zj_colorWithHexString:@"ffaaab"];
            label.text = @"更多";
            label.backgroundColor = [UIColor clearColor];
            label.font = [UIFont systemFontOfSize:14 * [UIScreen zj_textFontScale]];
            label;
        });
    }
    return _moreLabel;
}

- (UIImageView *)imageView{
    if (!_imageView) {
        _imageView = [UIImageView new];
        _imageView.image = [UIImage imageNamed:@"jiantou_right"];
        _imageView.contentMode = UIViewContentModeRight;
    }
    return _imageView;

}


@end
